home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 September
/
PCWorld_2006-09_cd.bin
/
v cisle
/
hexer
/
mpth_17.exe
/
{app}
/
scripts
/
copytexttoclipboard.mps
< prev
next >
Wrap
Text File
|
2006-05-23
|
1KB
|
57 lines
include '*.lng'
= copy the current selection (or whole file, if nothing selected) to clipboard in
= raw data format (as text)
= markus stephany, may 23, 2006
option opt5, 'copytexttoclipboard.ico':= set an icon for this script
= check if a file is currently open
IF (CURRENTFILE=="")
ERROR __ERR1__
ENDIF
= open current file
VAR curfile FILE
curfile = FILEOPEN("::current", "r")
IF (FILEGETPROP(curfile, "Size") == 0)
FILECLOSE curfile
ERROR __ERR2__
ENDIF
= open clipboard
VAR clip FILE
clip = FILEOPEN("::clipboard", "c")
= get selection/whole file margins
VAR start LONGWORD count LONGWORD
count = FILEGETPROP(curfile, "SelCount")
IF (count)
start = FILEGETPROP(curfile, "SelStart")
ELSE
start = 0
count = FILEGETPROP(curfile, "Size")
ENDIF
FILESEEK clip count
FILESEEK clip 0
= copy the part/file to the clipboard as CF_TEXT
VAR cnt LONGWORD transfer TEXT rem DWORD blocks DWORD
rem = count MOD 65536
blocks = count / 65536
FILESEEK curfile start
WHILE (blocks > 0)
INC cnt, 65536
INC blocks, -1
SHOWPROGRESS count cnt
FILEREAD curfile transfer 65536
FILEWRITE clip transfer
ENDWHILE
FILEREAD curfile transfer rem
FILEWRITE clip transfer
FILECLOSE curfile
FILECLOSE clip